package com.webauto.test_case;

import org.openqa.selenium.By;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.webauto.asserts.assertUtil;
import com.webauto.data_driver.CaseUtil;
import com.webauto.data_driver.ExcelUtil;
import com.webauto.log.Log;
import com.webauto.po.PO;
import com.webauto.pojo.Case;
import com.webauto.selenium.UseElementUtil;

public class Test3_ClientManager_Details extends BaseCase {
	/**
	 * PS:测试方法
	 * 
	 * @param testNum        测试编号
	 * @param caseNum        用例编号
	 * @param caseName       测试名称
	 * @param caseType       测试类型
	 * @param testData       测试数据
	 * @param expectedResult 预计结果
	 * @param actualResult   实际结果
	 */
	@Test(dataProvider = "datas")
	public void clientManager_Details(String testNum, String caseNum, String caseName, String caseType, String testData,
			String checkPoint, String expectedResult, String actualResult) {
		PO navigation = new PO("导航栏");
		navigation.click("客户管理");
		navigation.click("子集客户管理");
		PO clientManager = new PO("客户管理", testData);
		clientManager.switchToFrame("客户管理iframe");
		clientManager.click("查看按钮");
		clientManager.switchToFrame("查看窗口iframe");
		// 断言结果
		boolean flag = false;
		String result = null;
		try {
			// 获取检查点选择器对象
			By checkPointBy = clientManager.getByByCheckPoint(checkPoint);
			// 获取检查元素的文本
			result = UseElementUtil.getText(checkPointBy);
			// 断言
			flag = assertUtil.check(result, expectedResult);
		} catch (AssertionError e) {
			throw new AssertionError("+++用例" + caseNum + "执行未通过," + e.getMessage() + "+++");
		} finally {
			CaseUtil.writeData(flag, "用例", caseNum, "ActualResult", result);
		}
	}

	/**
	 * PS:数据提供者
	 * 
	 * @return 数据二维数组,Test方法会按照数组数量进行多次测试
	 */
	@DataProvider(name = "datas")
	public Object[][] datas() {
		Object[][] datas = CaseUtil.getExcelEntity("testNum", "test-003", ExcelUtil.cases, ExcelUtil.casefields,
				Case.class);
		return datas;
	}
}
